package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.KhjcPraiseCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.KhjcPraiseResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.KhjcPraiseUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.KhjcPraiseEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface KhjcPraiseConvert {
    KhjcPraiseConvert INSTANCE = Mappers.getMapper(KhjcPraiseConvert.class);

    KhjcPraiseResultDTO convert(KhjcPraiseEntity s);

    KhjcPraiseEntity createTo(KhjcPraiseCreateDTO s);

    KhjcPraiseEntity update(KhjcPraiseUpdateDTO s);

    default KhjcPraiseEntity create(KhjcPraiseCreateDTO s, Long tenantId) {
        KhjcPraiseEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        return entity;
    }
}
